{extend name="extra@admin/content"}

{block name="content"}
<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="__SELF__" data-auto="true" method="post">

    <div id="optionContainer">
        <div class="layui-form-item">
            <label class="layui-form-label">选择订货商品</label>
            <div class="layui-input-block">
                <select name="goods_id" lay-verify="" lay-search>
                    {volist name='list' id='voo'}
                    <option {if isset($vo.goods_id)}{if $vo.goods_id==$voo.id}selected{/if}{/if} value="{$voo.id}">{$voo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">订货数量</label>
            <div class="layui-input-block">
                <input required type="text" autofocus name="num" value="{$vo.num|default=''}" pattern="^[1-9]\d*$" title="请输入订货数量" placeholder="请输入订货数量" class="layui-input">
            </div>
        </div>
    </div>

    <!--<div style="text-align: center;">
        <a href="javascript:;" onclick="addRow()">添加一行</a>
    </div>-->

    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        {if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'/>{/if}
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
    <script>window.form.render();</script>

    <script>
        var rowCount=4;  //行数默认4行

        //添加行
        function addRow(){
//            var plus = '{ $html}';
            rowCount++;
            var newRow='<div id="option'+rowCount+'">'+plus+'<a href="javascript:;" onclick=delRow('+rowCount+')>删除</a></div>';
            $('#optionContainer').append(newRow);
        }

        //删除行
        function delRow(rowIndex){
            $("#option"+rowIndex).remove();
            rowCount--;
        }
    </script>
</form>

<!--<style>
    .ibox-content{
        overflow-y: scroll;
        overflow-x: hidden;
        height: 400px;
    }
</style>-->
{/block}


